namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0035 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.SysSearchResult",
                c => new
                    {
                        SearchId = c.Int(nullable: false, identity: true),
                        SearchKeyword = c.String(),
                        SearchTitleOnly = c.Boolean(nullable: false),
                        SearchByEmployeeName = c.String(),
                        SearchByEmployeeNameExactName = c.Boolean(nullable: false),
                        ResultAmount = c.Int(nullable: false),
                        RecordStatus = c.String(),
                        CreatedBy = c.Int(nullable: false),
                        CreatedWhen = c.DateTime(nullable: false),
                        UpdatedBy = c.Int(),
                        UpdatedWhen = c.DateTime(),
                        SeacrhOption = c.String(),
                        SortResultByType = c.String(),
                        SortResultOrdering = c.String(),
                    })
                .PrimaryKey(t => t.SearchId);
            
            CreateTable(
                "dbo.SysSearchResultDtl",
                c => new
                    {
                        SearchDtlId = c.Int(nullable: false, identity: true),
                        SearchId = c.Int(nullable: false),
                        DataId = c.Int(nullable: false),
                        DataCode = c.String(),
                        DataName = c.String(),
                        DataDescription = c.String(),
                        DataOtherText = c.String(),
                        DataSiteNavigatePath = c.String(),
                        DataFileImageUrl = c.String(),
                        DataSeacrhOptionEnum = c.String(),
                        ScoreCount = c.Int(nullable: false),
                        DataRecordStatus = c.String(),
                        DataCreatedBy = c.Int(),
                        DataCreatedByFullName = c.String(),
                        DataCreatedWhen = c.DateTime(),
                        DataUpdatedBy = c.Int(),
                        DataUpdatedByFullName = c.String(),
                        DataUpdatedWhen = c.DateTime(),
                    })
                .PrimaryKey(t => t.SearchDtlId)
                .ForeignKey("dbo.SysSearchResult", t => t.SearchId, cascadeDelete: true)
                .Index(t => t.SearchId);
            
            AlterColumn("dbo.IcmInventoryRepair", "RepairStatus", c => c.Int(nullable: false));
            AddForeignKey("dbo.IcmInventoryRepair", "RepairStatus", "dbo.IcmMasLookUp", "LookUpId", cascadeDelete: true);
            CreateIndex("dbo.IcmInventoryRepair", "RepairStatus");
        }
        
        public override void Down()
        {
            DropIndex("dbo.SysSearchResultDtl", new[] { "SearchId" });
            DropIndex("dbo.IcmInventoryRepair", new[] { "RepairStatus" });
            DropForeignKey("dbo.SysSearchResultDtl", "SearchId", "dbo.SysSearchResult");
            DropForeignKey("dbo.IcmInventoryRepair", "RepairStatus", "dbo.IcmMasLookUp");
            AlterColumn("dbo.IcmInventoryRepair", "RepairStatus", c => c.String());
            DropTable("dbo.SysSearchResultDtl");
            DropTable("dbo.SysSearchResult");
        }
    }
}
